<?php namespace modules\system;
/**
 * @subpackage  \modules\system
 *
 * @copyright   Copyright (C) 2013 - 2014 Mailerm, Inc. All rights reserved.
 */
# Load Libraries
require_once MPATH_MODULES . '/mod_user/mod_user.php';	
use \modules\user as mod_user;

# Load Configuration
require_once MPATH_MODULES . '/configuration.php';

// get system infor
function info($params, $method, $app) {
	// Check Role
	if (!mod_user\_user_belong(array(ROLE_MANAGER))) {
		$app->return_error(403, 'Forbidden', 'You don\'t have permission to access this server.');
		exit();
	}
	$result = array();
	$result['sys'] = $app->system();
	$result['build'] = php_uname();
	$result['php'] = PHP_VERSION;
	$result['time'] = date('Y-m-d h:i', time());
	$result['mysql'] = mysql_get_server_info();
	$result['server'] = $_SERVER['SERVER_SOFTWARE'];
	$result['agent'] = $_SERVER['HTTP_USER_AGENT'];
	$result['ver'] = _MVERSION;
	$app->return_json($result);
   	exit();
}

// get php setting
function php_settings($params, $method, $app) {
	// Check Role
	if (!mod_user\_user_belong(array(ROLE_MANAGER))) {
		$app->return_error(403, 'Forbidden', 'You don\'t have permission to access this server.');
		exit();
	}
	$result = array();
	$result['display_errors'] = ini_get('display_errors');
	$result['html_errors'] = ini_get('html_errors');
	$result['safe_mode'] = ini_get('safe_mode');
	$result['html_errors'] = ini_get('html_errors');
	$result['file_uploads'] = ini_get('file_uploads');
	$result['output_buffering'] = ini_get('output_buffering');
	$result['max_file_uploads'] = ini_get('max_file_uploads');
	$result['memory_limit'] = ini_get('memory_limit');
	$result['max_execution_time'] = ini_get('max_execution_time');
	$app->return_json($result);
   	exit();
}